<?php

   function  presentation_region($region)
   {
       echo'<span class="template_title">R&eacute;gion ';
       if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '. utf8_decode($region) .'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$region.' ';
                   }
               echo'</span></br>';
       
   }


function printWorks() {
    
    echo '<span class="template_title">R&eacute;gions de France</span></br>
            <a href="'.URL_ROOT.'oeuvres/region-alsace"><span class="template_region">Alsace</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-bassenormandie"><span class="template_region">Basse-Normandie</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-bretagne"><span class="template_region">Bretagne</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-centre"><span class="template_region">Centre</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-champagneardenne"><span class="template_region">Champagne-Ardenne</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-corse"><span class="template_region">Corse</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-franchecomte"><span class="template_region">Franche-Comt&eacute;</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-iledefrance"><span class="template_region">&Icirc;le-de-France</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-limousin"><span class="template_region">Limousin</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-midipyrenees"><span class="template_region">Midi-Pyr&eacute;n&eacute;es</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-nordpasdecalais"><span class="template_region">Nord-Pas-de-Calais</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-paysdelaloire"><span class="template_region">Pays de la Loire</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-poitoucharentes"><span class="template_region">Poitou-Charente</span></a>
            <a href="'.URL_ROOT.'oeuvres/region-rhonealpes"><span class="template_region">Rh&ocirc;ne-Alpes</span></a>
          
             
    ';

   
}

function printWorksRegion($work_name, $work, $id_work, $type_img) {
    switch ($type_img) {
        case 0 :
            $ext = 'png';
            break;
        case 1 :
            $ext = 'jpg';
            break;
        case 2 :
            $ext = 'jpeg';
            break;
        
        default :
            $ext = '';
            break;
    }
    echo '<div id="case" >
             
                ';
    
    echo '<a class="lien_event" href="' . URL_ROOT . 'oeuvres/details-' . $work . '">
              <img class="img_work" src="' . URL_IMG . 'works/' . $id_work . '.' . $ext . '" alt="" />
              </a>
              <a class="lien_event" href="' . URL_ROOT . 'oeuvres/details-' . $work . '">
                    
                    <div id="work">
                        <span id="worktitle">    
                            <span id="uptitle">';
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '. utf8_decode(raccourcirChaine(str_replace(chr(146), "'", $work_name), 20)) .'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.raccourcirChaine(str_replace(chr(146), "'", $work_name), 20).' ';
                   }
            echo'</span>
                            <span id="downtitle">Agrandir ' . raccourcirChaine($work_name, 10) . '</span>
                        </span>
                    </div>
             </a>
              </div>';
}

function printOneWork($like, $user_surname, $user_name, $work_name, $work_description, $work, $id_work, $type_img, $type_img2,$id_autor) {
    switch ($type_img) {
        case 0 :
            $ext = 'png';
            break;
        case 1 :
            $ext = 'jpg';
            break;
        case 2 :
            $ext = 'jpeg';
            break;
        default :
            $ext = '';
            break;
    }
    switch ($type_img2) {
        case 0 :
            $ext2 = 'png';
            break;
        case 1 :
            $ext2 = 'jpg';
            break;
        case 2 :
            $ext2 = 'jpeg';
            break;
        default :
            $ext2 = '';
            break;
    }
    echo ' 
            <span id="one_work_name">';
    
    if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '. utf8_decode(str_replace(chr(146), "'", $work_name)) .'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.str_replace(chr(146), "'", $work_name).' ';
                   }
           
                echo'</span>
            <div id="case2">
                <div id="wrapper" class="img_lightbox">

                    <div class="slider-wrapper theme-default">
                        <div id="slider" class="nivoSlider">      ';
    if (file_exists('design/img/works/' . $id_work . '.' . $ext) == true) {
        echo '<a id="img_lightbox" href="' . URL_IMG . 'works/' . $id_work . '.' . $ext . '" rel="lightbox" >
                                <img id="img_one_work" src="' . URL_IMG . 'works/' . $id_work . '.' . $ext . '" alt="" />';
    }
    if (file_exists('design/img/works2/' . $id_work . '.' . $ext2) == true) {
        echo '<a id="img_lightbox" href="' . URL_IMG . 'works2/' . $id_work . '.' . $ext2 . '" rel="lightbox" >
                                <img id="img_one_work" src="' . URL_IMG . 'works2/' . $id_work . '.' . $ext2 . '" alt="" />';
    }
function Pourcentage($Nombre, $Total) {
	return $Nombre * 100 / $Total;
}

//$dimension1=getimagesize('' . URL_IMG . 'works/' . $id_work . '.' . $ext . '');    
//$dimension2=getimagesize('' . URL_IMG . 'works2/' . $id_work . '.' . $ext2 . '');
    echo ' <style>               
#blocus {
    margin-top:100px;
}
</style>';

    echo '</div>

                </div></a>
                </div>
                    <span id="one_work_description_box">
                    <span id="one_work_description">' . $work_description . '</span>  
                    </span>
                </div>';



    echo ' <div id="blocus"><a href="' . URL_ROOT . 'profils/details-' . $id_autor . '">
                         
                      <span id="one_work_user" > <label id="attribut"> Publi&eacute; par :</label> '; 
    
    
                    
           if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) //pour détecter si le navigateur est IE
                  { 
                            echo' '.utf8_decode( $user_name) . ' ' .utf8_decode( $user_surname).'' ; 
                    }
                    else //les autres navigateurs 
                    {       
                        echo' '.$user_name. ' ' .$user_surname.' ';
                   }
                
                      
                    echo '</span></a></br>
              <span id="one_work_like" >
              <form action='. URL_ROOT . 'oeuvres/details-'.$id_work.' method="post" >  <input type="submit" value="Like"  ></br>
              <input type="hidden"  name = "work"  class="" value ='.$id_work.' />  <input type="hidden" class="" name = "like" value ='.$like.' /></form>
              </span>
              <img id="one_work_like_img" src="'.URL_IMG .'/menu/rate-up.png" alt="ecole du louvre" />
                    <span id="one_work_like" >'.$like.' personnes aiment &ccedil;a</span>
                        </div>
        
                    ';
}

function raccourcirChaine($chaine, $tailleMax) {
    // Variable locale
    $positionDernierEspace = 0;
    if (strlen($chaine) >= $tailleMax) {
        $chaine = substr($chaine, 0, $tailleMax);
        $positionDernierEspace = strrpos($chaine, ' ');
        $chaine = substr($chaine, 0, $positionDernierEspace) . '...';
    }
    return $chaine;
}


?>
